﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Esb.Domain.DomainObjects;

namespace Esb.Domain.Factories
{
    public class LogFactory : FactoryBase<OperationLogDo, int>
    {
        public LogFactory() : base("Esb")
        {

        }

        /// <summary>
        /// 新增日志
        /// </summary>
        /// <param name="log"></param>
        public OperationLogDo AddLog(OperationLogDo log)
        {
            Repository.Add(log);
            return log;
        }

        /// <summary>
        /// 根据Service的Id查询log
        /// </summary>
        /// <param name="serviceId"></param>
        /// <returns></returns>
        public List<OperationLogDo> GetLogsByServiceId(int serviceId)
        {
            Func<OperationLogDo, bool> queryCondition = (OperationLogDo log) =>
            {
                return log.ServiceId == serviceId;
            };

            IEnumerable<OperationLogDo> result = Repository.FindBySpecification(queryCondition);
            return result.ToList();
        }
    }
}
